<?php
define('APP_ENV', 'development');
//define('APP_ENV', 'production');
define('DS', DIRECTORY_SEPARATOR);
define('PS', PATH_SEPARATOR);
define('DOCUMENT_ROOT', realpath(dirname(__FILE__)));
define('ROOT_PATH', realpath(DOCUMENT_ROOT . DS . '..'));
define('APPLICATION_PATH', ROOT_PATH . DS . 'application');
define('LIBRARY_PATH', ROOT_PATH . DS . 'library');
define('STATIC_PATH', DOCUMENT_ROOT . DS . 'static');

//Setup Include Paths
set_include_path(implode(PATH_SEPARATOR,
    array(
        APPLICATION_PATH,
        LIBRARY_PATH,
        get_include_path()
    )
));

//Load bootstrap
try {
    //Load Application
    require 'Zend' . DS . 'Application.php';
    require APPLICATION_PATH . DS . 'configs' . DS . 'defined.php';
    require APPLICATION_PATH . DS . 'configs' . DS . 'global.php';

    $application = new Zend_Application(
        APP_ENV,
        APPLICATION_PATH . DS . 'configs' . DS . 'system.ini'
    );
	
    //Display
    $application->bootstrap()->run();

} catch (Exception $exception) {
    if (APP_ENV == 'development') {
        echo '<html><body><center>'
            . 'An exception occured while bootstrapping the application.';
        echo APP_ENV . '<br/>';
        echo '<br /><br />' . $exception->getMessage() . '<br />'
            . '<div align="left">Stack Trace:'
            . '<pre>' . $exception->getTraceAsString() . '</pre></div>';
        echo '</center></body></html>';
    } else {
        header('Location: /error');
    }

    exit(1);
}